programming4us
           
 
 
Programming

jQuery 1.3 : Improving a basic form (part 1) - The legend

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/6/2010 5:44:54 PM

The form's legend is a notoriously difficult element to style with CSS. Browser inconsistencies and positioning limitations make working with it an exercise in frustration. Yet, if we're concerned about using meaningful, well-structured page elements, the legend is an attractive, if not visually appealing, choice for displaying a title in our form's<fieldset>.

Left with only HTML and CSS, we're forced to compromise either semantic markup or flexible design choices. However, we can change the HTML as the page loads, turning each<legend> into an<h3> for people viewing the page, while machines reading the page&mdash;and those without JavaScript available&mdash;still see the<legend>. This can be done straightforwardly using jQuery's .replaceWith() method:

$(document).ready(function() {
$('legend').each(function(index) {
$(this).replaceWith('<h3>' + $(this).text() + '</h3>');
});
});

Notice here that we can't rely on jQuery's implicit iteration. With each element we replace, we need to insert that element's unique text contents. For this we rely on the .each() method, which allows us to target the particular text with $(this).

Now, when we apply a blue background and white text color to the<h3> in the stylesheet, the form's first fieldset looks like this:

An alternative approach that keeps the<legend> elements intact involves wrapping their contents with a<span> tag:

$(document).ready(function() {
$('legend').wrapInner('<span></span>');
});

Wrapping a<span> inside the<legend> has at least two advantages over replacing the<legend> with an<h3>: it retains the semantic meaning of the<legend> for screen readers with JavaScript support and it requires less work on the part of the script. The disadvantage is that it makes the heading style a little harder to achieve. At the very least, we have to set the position property of both the<fieldset> and the<span>, as well as the padding-top of the<fieldset> and the width of the<span>:

fieldset {
position: relative;
padding-top: 1.5em;
}
legend span {
position: absolute;
width: 100%;
}

Whether we choose to replace the form's<legend> elements or insert a<span> into them, they are now sufficiently styled for our purposes; it's time to clean up the required field messages.
Other -----------------
- Changes to Privacy Risk Management and Compliance in Relation to Cloud Computing
- Cloud Security and Privacy : What Are the Key Privacy Concerns in the Cloud?
- Cloud Security and Privacy : What Is the Data Life Cycle?
- Making Your Site Accessible to Search Engines
- Security Management in the Cloud - Security Vulnerability, Patch, and Configuration Management (part 2)
- Security Management in the Cloud - Security Vulnerability, Patch, and Configuration Management (part 1)
- Security Management in the Cloud - Access Control
- Security Management in the Cloud - IaaS Availability Management
- Security Management in the Cloud - PaaS Availability Management
- Security Management in the Cloud - SaaS Availability Management
- Security Management in the Cloud - Availability Management
- Security Management in the Cloud
- The Art of SEO : Trending, Seasonality, and Seasonal Fluctuations in Keyword Demand
- The Art of SEO : Leveraging the Long Tail of Keyword Demand
- The Art of SEO : Determining Keyword Value/Potential ROI
- Identity and Access Management : Cloud Service Provider IAM Practice
- Identity and Access Management : Cloud Authorization Management
- Identity and Access Management : IAM Practices in the Cloud (part 2) - Federated Identity
- Identity and Access Management : IAM Practices in the Cloud (part 1) - Cloud Identity Administration
- iPad SDK : Keyboard Extensions and Replacements (part 4) - Creating the Calculator
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us